{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ea068cdf",
   "metadata": {},
   "outputs": [],
   "source": [
    "from aplpy import FITSFigure, make_rgb_image\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c3b06370",
   "metadata": {},
   "outputs": [],
   "source": [
    "# List all the bone names\n",
    "ListNames = ['Fil1', 'Fil2', 'Fil4', 'Fil5', 'Fil8', 'Fil10', 'G24', 'G47', 'G49', 'Snake']\n",
    "# Colors\n",
    "RedStr = '24'\n",
    "GreenStr = '8'\n",
    "BlueStr = '3'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "2f647775",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Color  levels\n",
    "# Trick: Open RGB frames in DS9, set each color scale to ZScale, tweak green and blue\n",
    "# Red\n",
    "vmin_r = [14.9462, 19.0706, 24.5291, 27.1738, 25.478, 26.2257, 17.3235, 9.74913, 12.2078, 22.7023]\n",
    "vmax_r = [152.874, 143.506, 80, 148.918, 100.0, 138.843, 142.508, 35, 1200, 100]\n",
    "# Green\n",
    "vmin_g = [22.5966, 31.4887, 47.1352, 38.6248, 29.0035, 42.7135, 15.3235, 16.2756, 20.661, 41.5945]\n",
    "vmax_g = [150, 140, 120, 150, 120, 165.607, 160, 50, 264.192, 140]\n",
    "# Blue\n",
    "vmin_b = [1.34766, 1.8166, 1.90126, 2.60678, 3.43116, 1.33597, 1.65835, 0.590945, 0.569635, 1.87717]\n",
    "vmax_b = [40, 40, 40, 40, 40, 40, 40, 30, 30, 40]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ab530fc5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current RGB image: Fil1\n",
      "INFO: Red: [aplpy.rgb]\n",
      "INFO: vmin =  1.495e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.529e+02 [aplpy.rgb]\n",
      "INFO: Green: [aplpy.rgb]\n",
      "INFO: vmin =  2.260e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.500e+02 [aplpy.rgb]\n",
      "INFO: Blue: [aplpy.rgb]\n",
      "INFO: vmin =  1.348e+00 [aplpy.rgb]\n",
      "INFO: vmax =  4.000e+01 [aplpy.rgb]\n",
      "Current RGB image: Fil2\n",
      "INFO: Red: [aplpy.rgb]\n",
      "INFO: vmin =  1.907e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.435e+02 [aplpy.rgb]\n",
      "INFO: Green: [aplpy.rgb]\n",
      "INFO: vmin =  3.149e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.400e+02 [aplpy.rgb]\n",
      "INFO: Blue: [aplpy.rgb]\n",
      "INFO: vmin =  1.817e+00 [aplpy.rgb]\n",
      "INFO: vmax =  4.000e+01 [aplpy.rgb]\n",
      "Current RGB image: Fil4\n",
      "INFO: Red: [aplpy.rgb]\n",
      "INFO: vmin =  2.453e+01 [aplpy.rgb]\n",
      "INFO: vmax =  8.000e+01 [aplpy.rgb]\n",
      "INFO: Green: [aplpy.rgb]\n",
      "INFO: vmin =  4.714e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.200e+02 [aplpy.rgb]\n",
      "INFO: Blue: [aplpy.rgb]\n",
      "INFO: vmin =  1.901e+00 [aplpy.rgb]\n",
      "INFO: vmax =  4.000e+01 [aplpy.rgb]\n",
      "Current RGB image: Fil5\n",
      "INFO: Red: [aplpy.rgb]\n",
      "INFO: vmin =  2.717e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.489e+02 [aplpy.rgb]\n",
      "INFO: Green: [aplpy.rgb]\n",
      "INFO: vmin =  3.862e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.500e+02 [aplpy.rgb]\n",
      "INFO: Blue: [aplpy.rgb]\n",
      "INFO: vmin =  2.607e+00 [aplpy.rgb]\n",
      "INFO: vmax =  4.000e+01 [aplpy.rgb]\n",
      "Current RGB image: Fil8\n",
      "INFO: Red: [aplpy.rgb]\n",
      "INFO: vmin =  2.548e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.000e+02 [aplpy.rgb]\n",
      "INFO: Green: [aplpy.rgb]\n",
      "INFO: vmin =  2.900e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.200e+02 [aplpy.rgb]\n",
      "INFO: Blue: [aplpy.rgb]\n",
      "INFO: vmin =  3.431e+00 [aplpy.rgb]\n",
      "INFO: vmax =  4.000e+01 [aplpy.rgb]\n",
      "Current RGB image: Fil10\n",
      "INFO: Red: [aplpy.rgb]\n",
      "INFO: vmin =  2.623e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.388e+02 [aplpy.rgb]\n",
      "INFO: Green: [aplpy.rgb]\n",
      "INFO: vmin =  4.271e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.656e+02 [aplpy.rgb]\n",
      "INFO: Blue: [aplpy.rgb]\n",
      "INFO: vmin =  1.336e+00 [aplpy.rgb]\n",
      "INFO: vmax =  4.000e+01 [aplpy.rgb]\n",
      "Current RGB image: G24\n",
      "INFO: Red: [aplpy.rgb]\n",
      "INFO: vmin =  1.732e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.425e+02 [aplpy.rgb]\n",
      "INFO: Green: [aplpy.rgb]\n",
      "INFO: vmin =  1.532e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.600e+02 [aplpy.rgb]\n",
      "INFO: Blue: [aplpy.rgb]\n",
      "INFO: vmin =  1.658e+00 [aplpy.rgb]\n",
      "INFO: vmax =  4.000e+01 [aplpy.rgb]\n",
      "Current RGB image: G47\n",
      "INFO: Red: [aplpy.rgb]\n",
      "INFO: vmin =  9.749e+00 [aplpy.rgb]\n",
      "INFO: vmax =  3.500e+01 [aplpy.rgb]\n",
      "INFO: Green: [aplpy.rgb]\n",
      "INFO: vmin =  1.628e+01 [aplpy.rgb]\n",
      "INFO: vmax =  5.000e+01 [aplpy.rgb]\n",
      "INFO: Blue: [aplpy.rgb]\n",
      "INFO: vmin =  5.909e-01 [aplpy.rgb]\n",
      "INFO: vmax =  3.000e+01 [aplpy.rgb]\n",
      "Current RGB image: G49\n",
      "INFO: Red: [aplpy.rgb]\n",
      "INFO: vmin =  1.221e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.200e+03 [aplpy.rgb]\n",
      "INFO: Green: [aplpy.rgb]\n",
      "INFO: vmin =  2.066e+01 [aplpy.rgb]\n",
      "INFO: vmax =  2.642e+02 [aplpy.rgb]\n",
      "INFO: Blue: [aplpy.rgb]\n",
      "INFO: vmin =  5.696e-01 [aplpy.rgb]\n",
      "INFO: vmax =  3.000e+01 [aplpy.rgb]\n",
      "Current RGB image: Snake\n",
      "INFO: Red: [aplpy.rgb]\n",
      "INFO: vmin =  2.270e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.000e+02 [aplpy.rgb]\n",
      "INFO: Green: [aplpy.rgb]\n",
      "INFO: vmin =  4.159e+01 [aplpy.rgb]\n",
      "INFO: vmax =  1.400e+02 [aplpy.rgb]\n",
      "INFO: Blue: [aplpy.rgb]\n",
      "INFO: vmin =  1.877e+00 [aplpy.rgb]\n",
      "INFO: vmax =  4.000e+01 [aplpy.rgb]\n"
     ]
    }
   ],
   "source": [
    "for Name in ListNames:\n",
    "    # Reference and Output directories for the bone\n",
    "    print('Current RGB image: '+Name)\n",
    "    RefDir = 'Cubes/'\n",
    "    OutDir = 'Preview/'\n",
    "    # Finding the index for Name\n",
    "    i=ListNames.index(Name)\n",
    "    fitsname = RefDir+Name+'_RGB_cube_'+RedStr+'_'+GreenStr+'_'+BlueStr+'.fits'\n",
    "    pngname = OutDir+Name+'_RGB_cube_'+RedStr+'_'+GreenStr+'_'+BlueStr+'.png'\n",
    "    # Creating test RGB images\n",
    "    make_rgb_image(fitsname, pngname, vmin_r=vmin_r[i], vmin_g=vmin_g[i], vmin_b=vmin_b[i], vmax_r=vmax_r[i], vmax_g=vmax_g[i], vmax_b=vmax_b[i])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "PoLiteWIP",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
